<!-- 设备参数 -->
<template>
  <div class="dashboard-editor-container" style="min-width:1150px">
    <el-row style="background: #fff; padding: 16px 16px 0; margin-bottom: 32px">
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
        <el-button slot="append" @click="submit">保存设置</el-button>
        <el-tab-pane key="系统参数" label="系统参数" name="系统参数" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="180px">
              <div class="parameType-wrap">
                <div class="parameType">
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志默认显示天数:">
                    <el-input v-model.trim="deviceform.default_log_days" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志分页默认显示条数:">
                    <el-select v-model="deviceform.page_length" style="width:100%;">
                      <el-option label="10条/页" value=10></el-option>
                      <el-option label="20条/页" value=20></el-option>
                      <el-option label="30条/页" value=30></el-option>
                      <el-option label="40条/页" value=40></el-option>
                      <el-option label="50条/页" value=50></el-option>
                      <el-option label="100条/页" value=100></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="前端自动注销时长:">
                    <el-select v-model="deviceform.ui_logout_interval" style="width:100%;">
                      <el-option label="不自动注销" value=0></el-option>
                      <el-option label="5分钟" value=300></el-option>
                      <el-option label="10分钟" value=600></el-option>
                      <el-option label="15分钟" value=900></el-option>
                      <el-option label="30分钟" value=1800></el-option>
                      <el-option label="60分钟" value=3600></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <!-- <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="僵尸连接超时:">
                    <el-input v-model="deviceform.mainrsa_connect_zombie_timeout" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="最近性能日志缓存时长:">
                    <el-input v-model.trim="deviceform.cach_log_save_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="资产信息同步周期:">
                    <el-input v-model.trim="deviceform.sync_device_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区上送状态周期:">
                    <el-input v-model.trim="deviceform.report_device_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区网络心跳周期:">
                    <el-input v-model.trim="deviceform.echo_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="日志上送窗口时长:">
                    <el-input v-model.trim="deviceform.report_log_window_days" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="网络状态检测间隔:">
                    <el-input v-model.trim="deviceform.check_net_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="校区刷新配置参数间隔:">
                    <el-input v-model.trim="deviceform.refresh_param_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="根节点名称:" prop="root_corp_name" :rules="[{ required: true, message: '请输入根节点名称', trigger: 'blur' }]">
                    <el-input v-model.trim="deviceform.root_corp_name" maxlength="64"></el-input>
                  </el-form-item>
                </el-col>
                
                <el-col :xs="24" :sm="24" :lg="24">
                  <el-form-item label="数据备份机制:">
                    <el-checkbox true-label="1" false-label="0" v-model="deviceform.is_start_cfg_backup">备份配置文件</el-checkbox>
                    <el-checkbox true-label="1" false-label="0" v-model="deviceform.is_start_database_backup">备份数据库</el-checkbox>
                  </el-form-item>
                </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="性能阈值" label="性能阈值" name="性能阈值" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="150px">
              <div class="parameType-wrap">
                <div class="parameType">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="资产性能自检周期:">
                      <el-input v-model.trim="deviceform.check_dcd_perf_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="CPU使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.dcd_max_cpu_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.dcd_max_cpu_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="内存使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.dcd_max_mem_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.dcd_max_mem_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="磁盘空间阈值:">
                      <el-input v-model.trim="deviceform.dcd_max_disk_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="数据处理" label="数据处理" name="数据处理" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="180px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="16" :sm="16" :lg="16">
                    <el-form-item label="执行日志数据处理时间点:">
                      <el-select v-model="deviceform.AutoDelHours" style="width:100%;">
                        <!-- <el-option label="不执行数据处理" :value="0"></el-option> -->
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="14" :sm="14" :lg="14">
                    <el-form-item label="日志储存天数:">
                      <el-input v-model.trim="deviceform.LogSaveDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4" :disabled="deviceform.AutoDelHours === 0"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="10" :sm="10" :lg="10" style="margin-top:10px;"><span style="color:#aaa">(填0表示不执行数据自动删除)</span></el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="最近执行时间:">
                      <el-input v-model="deviceform.LastActTime" disabled oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <!-- <el-tab-pane key="首页参数" label="首页参数" name="首页参数" lazy>
          <div class="btn topSubmitBtn" style="width:530px">
            <el-button type="primary" @click="submitHomePage()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="130px">
              <div class="parameType-wrap">
                <div class="parameType">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="活动进程最近:">
                      <el-input v-model.trim="deviceform.processDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                    </el-form-item>
                    <el-form-item label="事件日志最近:">
                      <el-input v-model.trim="deviceform.EventLogDays" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="4"><span slot="append">天</span></el-input>
                    </el-form-item>
                    <el-form-item label="自动刷新间隔:">
                      <el-input v-model.trim="deviceform.AutomaticRefreshInterval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="5"><span slot="append">秒</span></el-input>
                    </el-form-item>
                    <el-form-item label="最大事件条数:">
                      <el-input v-model.trim="deviceform.EventLogTotal" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="事件严重性等级:">
                      <el-select v-model="deviceform.EventLevel" style="width:100%;">
                        <el-option label="全部" :value="0"></el-option>
                        <el-option label="紧急" :value="1"></el-option>
                        <el-option label="重要" :value="2"></el-option>
                        <el-option label="默认" :value="3"></el-option>
                        <el-option label="普通" :value="4"></el-option>
                        <el-option label="告知" :value="5"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane> -->
        <el-tab-pane key="装置维护" label="装置维护" name="装置维护" lazy>
          <div class="btn topSubmitBtn" style="width:680px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:680px">
                  <el-col :xs="16" :sm="16" :lg="16">
                    <el-form-item label="连续运行多长时间自动重启设备:">
                      <el-input v-model.trim="deviceform.reset_keep_run_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="8" :sm="8" :lg="8" style="margin-top:10px;"><span style="color:#aaa">(填0表示无效)</span></el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="每天指定时间自动重启设备:">
                      <el-select v-model="deviceform.reset_on_hours" style="width:100%;">
                        <el-option label="不执行定点自动重启" :value="0"></el-option>
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <!-- <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="60px">
                      <el-checkbox :true-label = 1 :false-label = 0 v-model="deviceform.is_start_n2n">开启网络维护透传服务，透传服务指令：</el-checkbox>
                      <el-input v-model="deviceform.maint_n2n_cmd"  maxlength="64" style="width:310px;margin-left:10px;"></el-input>
                    </el-form-item>
                  </el-col> -->
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="60px">
                      <el-checkbox :true-label = 1 :false-label = 0 v-model="deviceform.is_check_eth0_switch">启用检测网口90秒内连续插拔超过3次，自动恢复地址为：</el-checkbox>
                      <el-input v-model="deviceform.restore_ip"  maxlength="64" style="width:204px;margin-left:10px;"></el-input>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="终端参数" label="终端参数" name="终端参数" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理心跳间隔:">
                      <el-input v-model.trim="deviceform.agent_hand_shake_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理心跳超时次数:">
                      <el-input v-model.trim="deviceform.lost_hand_shake_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理网络连接检测间隔:">
                      <el-input v-model.trim="deviceform.check_agent_net_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理定时更新参数间隔:">
                      <el-input v-model.trim="deviceform.refresh_agent_param_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="终端代理自动升级检测间隔:">
                      <el-input v-model.trim="deviceform.agent_auto_upgrade_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="资产上送状态周期:">
                      <el-input v-model.trim="deviceform.report_device_status_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘显示控制:">
                      <el-radio v-model="deviceform.agent_show_trayicon" :label="1">显示</el-radio>
                      <el-radio v-model="deviceform.agent_show_trayicon" :label="0">隐藏</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘显示控制退出菜单:">
                      <el-radio v-model="deviceform.agent_show_trayicon_exit" :label="1">显示</el-radio>
                      <el-radio v-model="deviceform.agent_show_trayicon_exit" :label="0">隐藏</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘退出密码:">
                      <el-input v-model.trim="deviceform.agent_trayicon_exit_pwd" maxlength="36"></el-input>
                      <!-- <span style="color:#aaa">
                        （空表示不需要密码）
                      </span> -->
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="客户端托盘提示内容:">
                      <el-input v-model.trim="deviceform.agent_trayicon_tip" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="安装软件检测间隔:">
                      <el-input v-model.trim="deviceform.check_install_app_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="硬件变化检测间隔:">
                      <el-input v-model.trim="deviceform.check_hardware_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="6"><span slot="append">秒</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="安全软件版本检测提醒模式:">
                      <el-radio v-model="deviceform.security_check_mode" :label="0">不检测</el-radio>
                      <el-radio v-model="deviceform.security_check_mode" :label="1">开机提醒一次</el-radio>
                      <el-radio v-model="deviceform.security_check_mode" :label="2">定期检测提醒</el-radio>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="" label-width="220px">
                      <el-input v-model.trim="deviceform.security_check_interval" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="8" :disabled="deviceform.security_check_mode !== 2"><span slot="append">分钟</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="杀毒软件最新版本:">
                      <el-input v-model="deviceform.king_soft_av_client_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="病毒库最新版本:">
                      <el-input v-model="deviceform.king_soft_av_db_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="零信任最新版本:">
                      <el-input v-model="deviceform.trust_cyber_ver" maxlength="36"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px">（填空表示不检测）</p>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
        <el-tab-pane key="角色定义" label="角色定义" name="角色定义" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="addRole()">新增角色</el-button>
          </div>
          <el-table stripe border :data="tableData" style="width: 650px; margin-top: 15px" height="550">
            <el-table-column label="序号" width="80" type="index" :index='(index) => { return (index + 1) + (pageNum - 1) * pageSize }'> </el-table-column>
            <el-table-column label="角色" prop="Role" align="left" show-overflow-tooltip></el-table-column>
            <el-table-column label="操作" width="120px" align="left" fixed="right" >
              <template slot-scope="scope">
                <!-- <el-button type="primary" size="mini" @click="changeModer(scope.row)">修改</el-button> -->
                <el-button size="mini" type="danger" @click="deleteModer(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane key="管理中心" label="管理中心" name="管理中心" lazy>
          <div class="btn topSubmitBtn" style="width:650px">
            <el-button type="primary" @click="submit()">保存设置</el-button>
          </div>
          <div class="input-item"> 
            <el-form :model="deviceform"  label-width="220px">
              <div class="parameType-wrap">
                <div class="parameType" style="width:650px">
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="集中管理中心:">
                      <el-input v-model.trim="deviceform.center"  maxlength="64"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="CPU使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.center_dcd_max_cpu_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.center_dcd_max_cpu_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="内存使用率连续:">
                      <el-input style="width:150px" v-model.trim="deviceform.center_dcd_max_mem_keep_times" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="9"><span slot="append">次</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="12" :sm="12" :lg="12">
                    <el-form-item label="，超过:" label-width="120px">
                      <el-input v-model.trim="deviceform.center_dcd_max_mem_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="磁盘空间阈值:">
                      <el-input v-model.trim="deviceform.center_dcd_max_disk_percent" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">%</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="18" :sm="18" :lg="18">
                    <el-form-item label="连续运行多长时间自动重启设备:">
                      <el-input v-model.trim="deviceform.center_reset_keep_run_seconds" oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3"><span slot="append">天</span></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :xs="6" :sm="6" :lg="6">
                    <p style="color:#aaa;font-size:14px;line-height:10px;padding-left:5px;">(0表示不执行自动重启)</p>
                  </el-col>
                  <el-col :xs="24" :sm="24" :lg="24">
                    <el-form-item label="每天指定时间自动重启设备:">
                      <el-select v-model="deviceform.center_reset_on_hours" style="width:100%;">
                        <el-option label="不指定" value="0"></el-option>
                        <el-option v-for="item in 23" :key="item" :label="item + ':00'" :value="item"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </div>
              </div>
            </el-form>
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-row>
    <el-dialog 
      :close-on-click-modal="false" 
      :close-on-press-escape="false" 
      :title="Action === 1 ? `新增角色` : `修改角色`" 
      :visible.sync="moderVisible"
      v-el-drag-dialog  
      width="30%">
      <el-form label-width="120px" :model="partition" ref="partition">
        <el-form-item :label="`角色名称`" prop="Name">
          <el-input :placeholder="`请输入角色名称`" maxlength="10" v-model="partition.Role"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitRole()">确 定</el-button>
        <el-button type="info" @click="moderVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Cookies from 'js-cookie'
import { connrequest } from "@/api/firstPage"
import { formatDuration, parseTime } from '@/utils/index'
import elDragDialog from "@/directive/el-drag-dialog"; 
export default {
  directives: { elDragDialog },
  data() {
    return {
      Action: 1,
      pageNum: 1,
      pageSize: 10,
      moderVisible: false,
      partition: {},
      tableData: [],
      activeName: '系统参数',
      deviceform:{
      },
      oldData:[],
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    this.getData()
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {},
  methods: {
    async handleClick(tab){
      if(tab.label === '系统参数'){
        this.getData()
      }
      else if(tab.label === '性能阈值'){
        this.getData()
      }
      else if(tab.label === '数据处理'){
        this.getData()
      }
      else if(tab.label === '首页参数'){
        const res = await connrequest('GetFirstPageParam')
        this.deviceform = {...res.Data}
      }
      else if(tab.label === '装置维护'){
        this.getData()
      }
      else if(tab.label === '终端参数'){
        this.getData()
      }
      else if(tab.label === '角色定义'){
        this.GetParamDictRole()
      }
      else if(tab.label === '管理中心'){
        this.getData()
      }
    },
    async getData(){
      const res = await connrequest('GetParamThreshhold')
      const res1 = await connrequest('GetParamLogCfg')
      let obj = {}
      res.Data = res.Data || []
      res.Data.map( item  => {
        obj[item.Name] = item.Value
      })
      this.oldData = res.Data
      obj.center_reset_keep_run_seconds = obj.center_reset_keep_run_seconds ?  obj.center_reset_keep_run_seconds / 86400 : 0
      obj.reset_keep_run_seconds = obj.reset_keep_run_seconds ?  obj.reset_keep_run_seconds / 86400 : 0
      obj.cach_log_save_seconds = obj.cach_log_save_seconds / 3600 / 24
      obj.security_check_interval = obj.security_check_interval ? obj.security_check_interval / 60 : ''
      this.deviceform = {...obj, ...res1.Data, LastActTime: parseTime(res1.Data.LastActTime)}
    },
    async submit(){
      if(this.activeName === '系统参数' && this.deviceform.default_log_days < 1){
        this.$message.error('日志默认显示天数请设置最少为1天')
        return
      }
      if(this.activeName === '系统参数' && this.deviceform.cach_log_save_seconds < 1){
        this.$message.error('性能日志缓存时长请设置最少为1天')
        return
      }
      if(this.activeName === '终端参数' && this.deviceform.security_check_mode === 2 && !this.deviceform.security_check_interval){
        this.$message.error('请设置定期检测提醒时间')
        return
      }
      if(this.activeName === '终端参数'  && this.deviceform.security_check_mode === 2 && this.deviceform.security_check_interval < 1){
        this.$message.error('定期检测提醒时间最少为1分钟')
        return
      }
      // if(this.activeName === '数据处理' && this.deviceform.LogSaveDays < 1){
      //   this.$message.error('日志储存天数请设置最少为1天')
      //   return
      // }
      if(this.activeName === '装置维护'  && this.deviceform.is_check_eth0_switch * 1 === 1){
        const regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
        if (!regex.test(this.deviceform.restore_ip)) {
          this.$message.error('恢复地址的格式错误')
          return
        } 
      }
      let newObj = {...this.deviceform}
      newObj.center_reset_keep_run_seconds = newObj.center_reset_keep_run_seconds * 3600 * 24
      newObj.reset_keep_run_seconds = newObj.reset_keep_run_seconds * 3600 * 24
      newObj.cach_log_save_seconds = newObj.cach_log_save_seconds * 3600 * 24
      newObj.security_check_interval = newObj.security_check_interval * 60
      this.oldData = this.oldData.map(item => {
        for (const key in newObj) {
          if(item.Name === key){
            item.Value = newObj[key]
          }
        }
        return item
      })
      const data = {
        Data: this.oldData
      }
      const res = await connrequest('SetParamThreshhold', data)
      const data1 = {
        Data:{
          // ...this.deviceform
          AutoDelHours: this.deviceform.AutoDelHours,
          LogSaveDays: this.deviceform.LogSaveDays * 1,
          // LastActTime: this.deviceform.LastActTime,
        }
      }
      await connrequest('SetParamLogCfg', data1)
      if(res.Status.StatusCode === 0) {
        this.$message.success('保存成功')
        Cookies.set('DefaultLogDays', this.deviceform.default_log_days || 3)
        Cookies.set('DefaultPageLength', this.deviceform.page_length || 10)
        this.getData()
      }
    },
    async GetParamDictRole(){
      const res = await connrequest('GetParamDictRole')
      this.tableData = res.Data
    },
    addRole(){
      this.Action = 1
      this.$set(this.partition, 'Role', '')
      this.moderVisible = true
    },
    changeModer(row){
      this.Action = 2
      this.$set(this.partition, 'Role', row.Role)
      this.moderVisible = true
    },
    deleteModer(row){
      this.$confirm('删除角色前请先检查该角色是否存在改角色的资产和基于该角色配置策略规则。否则可能导致系统异常，请谨慎操作。确认要删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const data = {
          Data: {
            Action: 3,
            Detail: {...row}
          }
        }
        const res = await connrequest('EditParamDictRole', data)
        if(res.Status.StatusCode === 0){
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.GetParamDictRole()
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });          
      });
    },
    async submitHomePage(){
      const data = {
        Data:{
          processDays: this.deviceform.processDays * 1,
          EventLogDays: this.deviceform.EventLogDays * 1,
          AutomaticRefreshInterval: this.deviceform.AutomaticRefreshInterval * 1,
          EventLogTotal: this.deviceform.EventLogTotal * 1,
          EventLevel: this.deviceform.EventLevel * 1,
        }
      }
      const res = await connrequest('SetFirstPageParam',data)
      if(res.Status.StatusCode === 0) {
        this.$message.success('保存成功')
        this.handleClick('首页参数')
      }
    },
    async submitRole(){
      if(!this.partition.Role){
        this.$message.error('角色名称不能为空')
        return false
      }
      if(this.tableData.findIndex(item => item.Role == this.partition.Role) !== -1){
        this.$message.error('该角色已经存在')
        return false
      }
      const data = {
        Data: {
          Action: this.Action,
          Detail: {...this.partition}
        }
      }
      const res = await connrequest('EditParamDictRole', data)
      if(res.Status.StatusCode === 0){
        this.$message.success(this.Action === 1 ? '新增成功' : '修改成功')
        this.moderVisible = false
        this.GetParamDictRole()
      }
    },
  }
}
</script>
<style lang="scss" scoped>
/* @import url(); 引入css类 */
  .parameType-wrap{
    display:flex;
    flex-wrap: wrap;
  }
  ::v-deep.input-item{
    width: 1100px;
    margin-top: 10px;
    .parameType{
      border: 1px solid #eceff5;
      border-radius: 3px;
      width: 530px;
      padding: 10px;
      margin: 5px 10px 5px 0px;
      box-shadow: 0 0 10px #eceff5;
      .title{
        border-bottom: 1px solid #eceff5;
        padding-bottom : 10px;
      }
    }
    .el-form-item{
      margin-bottom: 6px;
    }
    .el-input-group__append, .el-input-group__prepend{
      width: 60px;
      padding: 0;
      text-align: center;
    }
  }
  .title{
    margin-bottom: 20px;
  }
  ::v-deep.el-form-item{
    label{
      font-weight: 500;
    }
  }
</style>